package com.zpark.serviceinterface.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zpark.domain.User;
import com.zpark.mapper.UserMapper;
import com.zpark.serviceinterface.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;

    @Override
//    @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
    public PageInfo<User> queryByPage(Integer curPage, Integer pageSize) {
        // 设置分页的相关信息
        PageHelper.startPage(curPage, pageSize);
        // 查询数据
        List<User> users = userMapper.selectAll();
        // 将查询到的数据整合到分页信息对象中
        PageInfo<User> pageInfo = new PageInfo<>(users);
        // 返回数据
        return pageInfo;
//        return new PageInfo<User>(userList);
    }
}
